package com.bhs.sansonglogistics.ui.orderDispose;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;

import android.os.Bundle;
import android.widget.TextView;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.base.BaseActivity;
import com.bhs.sansonglogistics.base.BaseFragment;
import com.bhs.sansonglogistics.ui.consumptionCoupon.CouponDetailListFragment;
import com.bhs.sansonglogistics.ui.home.FragmentAdapter;
import com.bhs.sansonglogistics.view.SelectedFont2;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

import java.util.ArrayList;

/**
 * 异常订单容器
 */
public class AbnormalOrderActivity extends BaseActivity {


    private TabLayout mTabLayout;
    private ViewPager2 mViewPage;

    @Override
    public int initLayout() {
        return R.layout.activity_abnormal_order2;
    }

    @Override
    public void initView() {
        TextView mTvTitle = findViewById(R.id.tv_title);
        mTabLayout = findViewById(R.id.tabLayout);
        mViewPage = findViewById(R.id.view_page);
        mTvTitle.setText("异常订单");
    }

    @Override
    public void initData() {
        mTabLayout.setTabMode(TabLayout.MODE_FIXED);
        //tab切换时候的字体设置
        mTabLayout.addOnTabSelectedListener(new SelectedFont2(mActivity));
        ArrayList<BaseFragment> fragments = new ArrayList<>();
        fragments.add(AbnormalOrderListFragment.newInstance("1,2,3,5"));
        fragments.add(AbnormalOrderListFragment.newInstance("7"));
        fragments.add(AbnormalOrderListFragment.newInstance("9"));
        mViewPage.setOffscreenPageLimit(fragments.size());
        mViewPage.setAdapter(new FragmentAdapter(this, fragments));
        String[] title = {"处理中", "处理完成", "已撤销"};
        new TabLayoutMediator(mTabLayout, mViewPage, new TabLayoutMediator.TabConfigurationStrategy() {
            @Override
            public void onConfigureTab(@NonNull TabLayout.Tab tab, int position) {
                tab.setText(title[position]);
            }
        }).attach();
    }
}